<%-- 
    Document   : Share
    Created on : Oct 25, 2014, 6:12:51 PM
    Author     : user
--%>


<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page  import="newpackage.ConnectionFactory" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body background="image.jpg">
        <h1> ENSURING PRIVACY AND DATA FRESHNESS OF SHARED DATA IN CLOUD </h1>
        <center>
    <%
    
Connection con=ConnectionFactory.getConnection();
Statement select=con.createStatement();
String user_name="";
String file_name="";
if(session.getAttribute("file_name")!=null&&session.getAttribute("user_name")!=null)
       {
     user_name=(String)session.getAttribute("user_name");
     file_name=(String)session.getAttribute("file_name");
}
String s="select id from file_details where owner='"+user_name+"' and filename='"+file_name+"'";
ResultSet rs=select.executeQuery(s);
int id=0;
if(rs.next())
       {
    id=rs.getInt(1);
}

Statement insertStatement=con.createStatement();
String uname[]=request.getParameterValues("shared_user");
for(String name:uname)
       {
String insertquery="insert into shared(user_name,id_fk) values('"+name+"','"+id+"')";
insertStatement.addBatch(insertquery);
}
insertStatement.executeBatch();
%>
File Shared Successfully !!
<a href="Login.jsp">Logout</a>
</center>
    </body>
</html>
